package huffmancode;

public class Node implements Comparable<Node>{
    private Byte aByte;
    private Integer val;
    private Node left;
    private Node right;

    public Node(Byte aByte, Integer val) {
        this.aByte = aByte;
        this.val = val;
    }

    public Node(Integer val) {
        this.val = val;
    }

    public Byte getaByte() {
        return aByte;
    }

    public void setaByte(Byte aByte) {
        this.aByte = aByte;
    }

    public Integer getVal() {
        return val;
    }

    public void setVal(Integer val) {
        this.val = val;
    }

    public Node getLeft() {
        return left;
    }

    public void setLeft(Node left) {
        this.left = left;
    }

    public Node getRight() {
        return right;
    }

    public void setRight(Node right) {
        this.right = right;
    }

    @Override
    public String toString() {
        return "Node{" +
                "aByte=" + aByte +
                ", val=" + val +
                '}';
    }

    @Override
    public int compareTo(Node node) {
        return this.val-node.val;
    }
    /*
     前序遍历
     */
    public void preSelect(Node root){
        System.out.println(root);
        if(root.getLeft()!=null){
            preSelect(root.getLeft());
        }
        if(root.getRight()!=null){
            preSelect(root.getRight());
        }
    }
}
